{extend name="common/base_page" /}

{block name="title"}库存设置{/block}

{block name="jscssfile"}{/block}

{block name="css"}
<style type="text/css">
body{ background: #ffffff; height:100vh; }
.layui-fluid {
    padding:10px 15px;
}
.layui-tab {
    margin: 0 0;
}
.layui-tab-content{  
  padding:0px;
}
.layui-tab-content .layui-tab-item{
  height:100vh;
}
#bar_box_one{
  padding: 0px 0px 5px 0px;
  margin-bottom:0px;
}
.layui-table, .layui-table-view { margin:0; }
.layui-form-item .layui-input-inline { margin-right: 0px; }
</style>
{/block}

{block name="body"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12" style="height:100vh;padding:0;">

            <div class="layui-form-item" id="bar_box_one">
                <a class="layui-btn layui-btn-warm" href="{:url('index/store.kucun/index')}">返回</a>
                <div class="layui-input-block" style="float: right;">
                  <form class="layui-form" action="">
                      <div class="layui-inline" style="margin-right:0px;">
                        <label class="layui-form-label" style="width:30px;padding: 9px 15px 9px 0;">&nbsp;</label>
                        <div class="layui-input-inline" style="width:100px;">
                          <input type="checkbox" id="hgh_noset" name="hgh_noset" value="1" title="未设置货柜号" lay-skin="primary">
                        </div>
                      </div>
                      <div class="layui-inline" style="margin-right:0px;">
                        <label class="layui-form-label" style="width:30px;padding: 9px 15px 9px 0;">&nbsp;</label>
                        <div class="layui-input-inline" style="width:130px;">
                          <input type="checkbox" id="zero_noshow" name="zero_noshow" value="1" title="零库存不显示" lay-skin="primary">
                        </div>
                      </div>
                      <div class="layui-inline">
                        <label class="layui-form-label" style="width:30px;padding: 9px 15px 9px 0;">类型</label>
                        <div class="layui-input-inline">
                          <select id="drug_type" name="drug_type">
                              <option value="ALL">全部</option>
                              {volist name="ypkc_type_list" id="vo"}
                              <option value="{$vo.id}">{$vo.name}</option>
                              {/volist}
                          </select>
                        </div>
                      </div>
                      <div class="layui-inline">
                        <div class="layui-input-inline">
                          <input type="text" name="keyword" id="keyword" maxlength="10" placeholder="名称/拼音码/五笔码" autocomplete="off" class="layui-input">
                        </div>
                      </div>
                      <div class="layui-inline">
                          <a class="layui-btn layui-btn-normal" onclick="_p = 1;_loadList();">搜索</a>
                      </div>
                    </form>
                </div>
            </div>
            <div class="layui-tab-content">
                  <div class="layui-tab-item layui-show">
                      <table id="LAY-app-content-comm" lay-filter="LAY-app-content-comm"></table>
                  </div>
            </div>

        </div>
    </div>
</div>
{/block}

{block name="script"}
<script type="text/javascript">
var _p = 1;
$(function(){
  setTimeout(function(){
      _loadList();
  },50);
});
</script>
<script type="text/javascript">
//加载数据
function _loadList()
{
      __showLoadingBox('请稍候...');
      var _hgh_noset = 0, _zero_noshow = 0;
      if($('#hgh_noset').prop('checked')) _hgh_noset = 1;
      if($('#zero_noshow').prop('checked')) _zero_noshow = 1;
      laytable.render({
          elem: '#LAY-app-content-comm'//指定表格元素
          ,url:"{:url('index/store.kucun/kucun_set')}"
          ,method:'post'  //提交方式
          ,where:{drugtype:$.trim($('#drug_type').val()),keyword:$.trim($('#keyword').val()),hghnoset:_hgh_noset,zeronoshow:_zero_noshow,page:_p} //post json数据
          ,page: {layout: ['count', 'prev', 'page', 'next', 'skip'],first: true,last: true}
          ,skin: 'line '  //表格风格 line （行边框风格）row （列边框风格）nob （无边框风格）
        　,even: true    //隔行换色
          ,limit: 20     //每页默认显示的数量
          ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
          ,height: 'full-100' //表格高度，layui 2.2.1 新增 , full-100 为适应最大高度或其它数值500
          ,cols: [[
            {field:'xm_type_txt', width:120, title: '药品类型'}
            ,{field:'name', minwidth:200, title: '名称'}
            ,{field:'spec', width:120, align:'center', title: '规格',sort: true}
            ,{field:'price', width:130, align:'center', title: '零售价',sort: true}
            ,{field:'ls_unit', width:100, align:'center', title: '单位'}
            ,{field:'cost_price', width:130, align:'center', title: '<i class="layui-icon layui-icon-edit"></i>&nbsp;进货价',sort: true, edit: 'text'}
            ,{field:'stock', width:150, align:'center', title: '库存',sort: true}
            ,{field:'huogui_no', width:150, align:'center', title: '<i class="layui-icon layui-icon-edit"></i>&nbsp;货柜号',sort: true, edit: 'text'}
            ,{field:'stock_max', width:150, align:'center', title: '<i class="layui-icon layui-icon-edit"></i>&nbsp;库存上限',sort: true, edit: 'text'}
            ,{field:'stock_min', width:150, align:'center', title: '<i class="layui-icon layui-icon-edit"></i>&nbsp;库存下限',sort: true, edit: 'text'}
          ]]
          ,done:function(datalist,curr,page){
              __hideLoadingBox();
          }
      });
      //监听单元格编辑
      laytable.on('edit(LAY-app-content-comm)', function(obj){
          var value = obj.value //得到修改后的值
          ,data = obj.data //得到所在行所有键值
          ,field = obj.field; //得到字段
          _Index.ajaxHide("{:url('index/store.kucun/kucun_set')}",{action:'edit',id:data.id,field:field,value:value},function(d){
              if(d.err == 0)
              {
                layer.msg(d.msg, {time: 500},function(){ });
              }else{
                layer.msg(d.msg, {time: 2000,anim: 4});
              }
          });
      });
}
</script>
{/block}